

package TransportesMarroquin;

import com.mysql.jdbc.Connection;

import java.awt.event.ActionEvent; 
import java.awt.event.KeyEvent; 
import javax.swing.JButton; 
import javax.swing.JLabel; 
import javax.swing.JPanel; 
import javax.swing.JTextField;
import com.mysql.jdbc.ResultSetMetaData;
import com.mysql.jdbc.Statement;
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;


public class ClienteSelect extends javax.swing.JFrame {
int num;

Limitador limcd = new Limitador(11);
Limitador limemp = new Limitador(30);
Limitador limnit = new Limitador(20);
Limitador limnom = new Limitador(30);
Limitador limtel = new Limitador(8);
Limitador limnape = new Limitador(50);
    public ClienteSelect(int cod) {
        initComponents();
        acep.setVisible(false);  // inicialmente se oculta 
        bcan.setVisible(false);  // inicialmente se oculta 
      
       this.num=cod;
        cd.setText(""+num);
        this.cod.setText(""+num);
 cd.setDocument(limcd);
 cemp.setDocument(limemp);
 cnit.setDocument(limnit);
 cnom.setDocument(limnom);
 ctel.setDocument(limtel);
 cape.setDocument(limnape);


      
        try {

                // coneccion a la base de datos
        MysqlDataSource datasource= new MysqlDataSource();
        datasource.setUser("root");
        datasource.setPassword("");
        datasource.setDatabaseName("practicasp8");
        datasource.setServerName("localhost");

          Connection conexion = (Connection) datasource.getConnection();


        Statement s = (Statement) conexion.createStatement();

 // query database
 ResultSet resultSet = s.executeQuery( "SELECT * FROM cliente where idcliente="+num);
        ResultSetMetaData metaData = (ResultSetMetaData) resultSet.getMetaData();
         int numerodecolumnas = metaData.getColumnCount();


       while (resultSet.next()){
        for(int i=1;i<=numerodecolumnas;i++){
             switch(i){
                 // creo este switch par delimitar el nombre de los label ya establecidos :D
                 case 1:
                     cd.setText(""+resultSet.getObject(i));
                   break;
                 case 2:
                    cnom.setText(""+resultSet.getObject(i));
                   break;
                 case 3:
                     cape.setText(""+resultSet.getObject(i));
                   break;
                 case 4:
                     cnit.setText(""+resultSet.getObject(i));
                   break;
                 case 5:
                     ctel.setText(""+resultSet.getObject(i));
                   break;
                 case 6:
                     cemp.setText(""+resultSet.getObject(i));
                   break;

             }

         } // fin del for
       } // fin del while 

        } catch (SQLException ex) {
            Logger.getLogger(ClienteSelect.class.getName()).log(Level.SEVERE, null, ex);
        } // fin del try and catch

    } //fin del constructor

    private ClienteSelect() {
        throw new UnsupportedOperationException("Not yet implemented");

    }

 
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel4 = new javax.swing.JLabel();
        breg = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        cd = new javax.swing.JTextField();
        cnom = new javax.swing.JTextField();
        ctel = new javax.swing.JTextField();
        cnit = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        cemp = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        bconf = new javax.swing.JButton();
        acep = new javax.swing.JButton();
        bcan = new javax.swing.JButton();
        cape = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        cod = new javax.swing.JLabel();
        n = new javax.swing.JLabel();
        lnum2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("C l i e n t e ");

        jLabel4.setText("N I T");

        breg.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/regresar.png"))); // NOI18N
        breg.setText("Regresar");
        breg.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bregActionPerformed(evt);
            }
        });

        jLabel1.setText("C o d i g o ");

        jLabel2.setText("N o m b r e");

        jLabel3.setText("T e l e f o n o");

        cd.setEnabled(false);
        cd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cdActionPerformed(evt);
            }
        });
        cd.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                cdKeyTyped(evt);
            }
        });

        cnom.setEnabled(false);
        cnom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cnomActionPerformed(evt);
            }
        });
        cnom.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                cnomKeyTyped(evt);
            }
        });

        ctel.setEnabled(false);
        ctel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ctelActionPerformed(evt);
            }
        });
        ctel.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                ctelKeyTyped(evt);
            }
        });

        cnit.setEnabled(false);
        cnit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cnitActionPerformed(evt);
            }
        });

        jLabel5.setText("E m p r e s a");

        cemp.setEnabled(false);
        cemp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cempActionPerformed(evt);
            }
        });
        cemp.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                cempKeyTyped(evt);
            }
        });

        jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Pilotos2.gif"))); // NOI18N

        bconf.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/config.png"))); // NOI18N
        bconf.setText("Configurar");
        bconf.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bconfActionPerformed(evt);
            }
        });

        acep.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/aceptar.png"))); // NOI18N
        acep.setText("Aceptar");
        acep.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                acepActionPerformed(evt);
            }
        });

        bcan.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/cancelar.png"))); // NOI18N
        bcan.setText("Cancelar");
        bcan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bcanActionPerformed(evt);
            }
        });

        cape.setEnabled(false);
        cape.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                capeActionPerformed(evt);
            }
        });
        cape.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                capeKeyTyped(evt);
            }
        });

        jLabel7.setText("Apellido");

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/iviaje.png"))); // NOI18N
        jButton3.setText("Viajes ");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(143, 0, 0));

        cod.setFont(new java.awt.Font("Tahoma", 1, 18));
        cod.setForeground(new java.awt.Color(255, 255, 255));
        cod.setText("####");

        n.setFont(new java.awt.Font("Tahoma", 1, 18));
        n.setForeground(new java.awt.Color(255, 255, 255));
        n.setText("No.");

        lnum2.setFont(new java.awt.Font("Tahoma", 1, 18));
        lnum2.setForeground(new java.awt.Color(255, 255, 255));
        lnum2.setText("Cliente");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lnum2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 155, Short.MAX_VALUE)
                .addComponent(n)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cod, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lnum2)
                    .addComponent(cod, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(n))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel1)
                        .addGap(19, 19, 19)
                        .addComponent(cd, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel2)
                        .addGap(18, 18, 18)
                        .addComponent(cnom, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel7)
                        .addGap(33, 33, 33)
                        .addComponent(cape, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel3)
                        .addGap(7, 7, 7)
                        .addComponent(ctel, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel4)
                        .addGap(47, 47, 47)
                        .addComponent(cnit, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel5)
                        .addGap(11, 11, 11)
                        .addComponent(cemp, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(4, 4, 4)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(bconf, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(acep, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(7, 7, 7)
                        .addComponent(bcan, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(breg, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(14, Short.MAX_VALUE))
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(cd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel2))
                    .addComponent(cnom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(16, 16, 16)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel7))
                    .addComponent(cape, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(16, 16, 16)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(ctel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel4))
                    .addComponent(cnit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(cemp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addComponent(jButton3)
                        .addGap(5, 5, 5)
                        .addComponent(bconf)
                        .addGap(5, 5, 5)
                        .addComponent(acep))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(85, 85, 85)
                        .addComponent(bcan)))
                .addGap(6, 6, 6)
                .addComponent(breg))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bregActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bregActionPerformed
        dispose();
        Cliente va;
       
            va = new Cliente();
            va.setVisible(true);
            va.setBounds(114, 107, Toolkit.getDefaultToolkit().getScreenSize().width-114, Toolkit.getDefaultToolkit().getScreenSize().height-107);

      
    }//GEN-LAST:event_bregActionPerformed

    private void cdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cdActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cdActionPerformed

    private void cnomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cnomActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cnomActionPerformed

    private void ctelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ctelActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ctelActionPerformed

    private void cnitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cnitActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cnitActionPerformed

    private void cempActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cempActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cempActionPerformed

    private void bconfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bconfActionPerformed
// obtener el dato de la llave primaria 
        
       
        
        
      acep.setVisible(true);   // muestro aceptar. 
      bcan.setVisible(true);
      breg.setVisible(false);
      // VOY A HABILITAR LOS CAMPOS DE TEXTO 
 cd.setEnabled(false);
 cemp.setEnabled(true);  
 cnit.setEnabled(true);
 cnom.setEnabled(false); 
 ctel.setEnabled(true);
 cape.setEnabled(false);
    }//GEN-LAST:event_bconfActionPerformed

    private void bcanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bcanActionPerformed
      breg.setVisible(true);  // muestro el regresar 
      acep.setVisible(false);
      bcan.setVisible(false);
      
       // REGRESO A OCULTAR LOS DATOS 
 cd.setEnabled(false);
 cemp.setEnabled(false);  
 cnit.setEnabled(false);
 cnom.setEnabled(false); 
 ctel.setEnabled(false);
 cape.setEnabled(false);
           
    }//GEN-LAST:event_bcanActionPerformed

    private void acepActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acepActionPerformed
       //  opcion 
       //UPDATE 
        
    
        try {
            // coneccion
              //CONFIGURAR 
        MysqlDataSource dataSource = new MysqlDataSource();
            dataSource.setUser("root");
            dataSource.setPassword("");
            dataSource.setDatabaseName("practicasp8");
            dataSource.setServerName("localhost");
           Connection conexion = (Connection) dataSource.getConnection();
            Statement instruccion = null;
            instruccion=(Statement) conexion.createStatement();
          // cambio los valores   
            instruccion.executeUpdate("update cliente set idcliente='"+cd.getText()+"' where idcliente="+num);
            instruccion.executeUpdate("update cliente set nombre='"+cnom.getText()+"' where idcliente="+num);
            instruccion.executeUpdate("update cliente set telefono='"+ctel.getText()+"' where idcliente="+num);
            instruccion.executeUpdate("update cliente set nit='"+cnit.getText()+"' where idcliente="+num);
            instruccion.executeUpdate("update cliente set empresa='"+cemp.getText()+"' where idcliente="+num);
            instruccion.executeUpdate("update cliente set apellido='"+cape.getText()+"' where idcliente="+num);
            
           
          JOptionPane.showMessageDialog(rootPane, "Dato cambiado exitosamente" );
          
          acep.setVisible(false);
          bcan.setVisible(false);
          bconf.setVisible(true);
          breg.setVisible(true);
          
            cd.setEnabled(false);
 cemp.setEnabled(false);
 cnit.setEnabled(false);
 cnom.setEnabled(false);
 ctel.setEnabled(false);
 cape.setEnabled(false);
           
        } catch (SQLException ex) {
                JOptionPane.showMessageDialog(rootPane, "Se ha producido un error al tratar de cambiar el dato. " );
        }
            
           
    }//GEN-LAST:event_acepActionPerformed

    private void capeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_capeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_capeActionPerformed

    private void cdKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cdKeyTyped
             char c = evt.getKeyChar();
       if(!(Character.isDigit(c))|| c== evt.VK_BACK_SPACE || c==evt.VK_DELETE){
           getToolkit().beep();
           evt.consume();
       }
    }//GEN-LAST:event_cdKeyTyped

    private void ctelKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_ctelKeyTyped
             char c = evt.getKeyChar();
       if(!(Character.isDigit(c))|| c== evt.VK_BACK_SPACE || c==evt.VK_DELETE){
           getToolkit().beep();
           evt.consume();
       }
    }//GEN-LAST:event_ctelKeyTyped

    private void cnomKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cnomKeyTyped
          char c = evt.getKeyChar();
      if (!(Character.isLetter(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE) || ((c== KeyEvent.VK_SPACE)))) {
            getToolkit().beep();
            evt.consume();
}
    }//GEN-LAST:event_cnomKeyTyped

    private void capeKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_capeKeyTyped
          char c = evt.getKeyChar();
      if (!(Character.isLetter(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE) || ((c== KeyEvent.VK_SPACE)))) {
            getToolkit().beep();
            evt.consume();
}
    }//GEN-LAST:event_capeKeyTyped

    private void cempKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cempKeyTyped
             char c = evt.getKeyChar();
      if (!(Character.isLetter(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE) || ((c== KeyEvent.VK_SPACE)))) {
            getToolkit().beep();
            evt.consume();
}
    }//GEN-LAST:event_cempKeyTyped

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        dispose();
        
        
        Viaje vap = new Viaje("select * from viaje where id_cliente="+num,"Cliente No.",num);
        vap.setVisible(true);
        
        vap.setBounds(114, 107, Toolkit.getDefaultToolkit().getScreenSize().width-114, Toolkit.getDefaultToolkit().getScreenSize().height-107);
}//GEN-LAST:event_jButton3ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ClienteSelect().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton acep;
    private javax.swing.JButton bcan;
    private javax.swing.JButton bconf;
    private javax.swing.JButton breg;
    private javax.swing.JTextField cape;
    private javax.swing.JTextField cd;
    private javax.swing.JTextField cemp;
    private javax.swing.JTextField cnit;
    private javax.swing.JTextField cnom;
    private javax.swing.JLabel cod;
    private javax.swing.JTextField ctel;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lnum2;
    private javax.swing.JLabel n;
    // End of variables declaration//GEN-END:variables

}
